<div class="row-fluid lines" style="padding-top: 20px;padding-bottom: 20px">
	<div  style="padding-left: 20px;" >
		<input type="hidden" name="user" value="<?php echo ucfirst($this->common_model->get_username_id($this->session->userdata('user_id')));?>" readonly />
		<span style="font-size: 40px">Client Billing Details</span>
		<br	/>
		<span style="font-size: 14px" class="muted">			
		<br>
	<br>
	<?php 
		$i=0;
		foreach($cycle_by_client_id as $cycle_by_client_id_row)
			{
				$billing_cycle[$i] = $cycle_by_client_id_row;
				$i++;
			}
	?>
	</br>	
	</div>
</div>
<div class="row-fluid">
<form action="<?php echo site_url('user/billing/total_bill');?>" method="POST">
	<table class="table">		
		<tr>
			<td>
				<select class="chzn-select" name="user">
					
					<?php foreach($users as $user){
						if($this->ion_auth->is_client($user->id)){						
						?>
					<option value="<?php echo $user->id;?>" <?php if($user_id == $user->id) {echo 'selected';} ?> ><?php echo $user->username?></option>
					<?php } }?>
				</select>				
			</td>
			<td><input type="submit" value="Apply" class="btn"/></td>
			<td></td>
		</tr>
	</table>
	</form>
</div>
<div>
</br>
</br>
<?php
 if(isset($result) OR !empty($result))
	{
		$i=0;
		foreach($project as $project_row)
			{
				echo("</br>" . "<div class=\"span4\"><h3>Project Name: ".$project_row['name']."</h3></div>");
				echo("<div class=\"span4 offset3\"><h3>Billing Cycle: ". $billing_cycle[$i] ."</h3></div>");
				$i++;
				foreach($result as $result_row)
					{
						if($project_row['id'] == $result_row['project_id'])
							{
?>
								<table width="80%" class="table table-condensed">
									<thead>
										<tr>			
											<th >
												Invoice ID
											</th>
											<th >
												Date
											</th>
											<th >
												Sub-Amount
											</th>
											<th >
												Discount
											</th>
											<th >
												Tax
											</th>
											<th >
												Total Amount
											</th>
											<th >
												Status
											</th>
										</tr>
									</thead>
			
									<tbody >		
										<tr>
											
											<td >
												<?php echo($result_row['invoice_id']);?></a>
											</td>
											<td >
												<?php echo ($result_row['date']);?>
											</td>
											<td >
												<?php echo ($result_row['subtotal']);?>
											</td>
											<td >
												<?php echo ($result_row['discount']);?>
											</td>
											<td >
												<?php echo ($result_row['tax']);?>
											</td>
											<td >
												<?php $total = $result_row['subtotal']-$result_row['discount'];  echo ($total);?>
											</td>
											<td >
											<span class="label label-<?php  if($result_row['status']=="0") echo ("important");
																			else echo("success");?>">
																	<?php  if($result_row['status']=="0") echo ("Not Paid");
																			else echo("Paid");?>
											</span>	
											</td>
										</tr>
									</tbody>		
								</table>	
<?php 

}
else 
	{
		echo("<div class=\"span11\" style=\"text-align:center\"><h3>Empty!! No Invoice Found</h3></div>");
		break;
	}
?>

<?php }
}

}

?>
</div>
